@import '../global/variables.css';

/* stylelint-disable color-no-hex */
:root {
  --ring-loader-color-1: #3bea62;
  --ring-loader-color-2: #6b57ff;
  --ring-loader-color-3: #07c3f2;
}
/* stylelint-enable */

@keyframes rotation-keyframes {
  100% {
    transform: rotate(360deg);
  }
}

.canvas {
  display: block;

  margin: calc(var(--ring-unit) * 2) auto;

  pointer-events: none;
}

.squares {
  position: relative;

  width: 60px;
  height: 60px;
}

@keyframes square-animation-main {
  0% {
    transform: rotate(0deg);
    animation-timing-function: cubic-bezier(0.333, 0, 0, 1);
  }

  37.5% {
    transform: rotate(182deg);
    animation-timing-function: cubic-bezier(0.333, 0, 0.657, 1);
  }

  50% {
    transform: rotate(180deg);
    animation-timing-function: cubic-bezier(0.333, 0, 0, 1);
  }

  87.5% {
    transform: rotate(362deg);
    animation-timing-function: cubic-bezier(0.333, 0, 0.657, 1);
  }

  100% {
    transform: rotate(360deg);
    animation-timing-function: cubic-bezier(0.333, 0, 0, 1);
  }
}

@keyframes square-animation-pseudo {
  0% {
    animation-timing-function: cubic-bezier(0.333, 0, 0, 1);

    opacity: 0;
  }

  18.75% {
    animation-timing-function: cubic-bezier(0.333, 0, 0.657, 1);

    opacity: 1;
  }

  25% {
    animation-timing-function: cubic-bezier(0.333, 0, 0, 1);

    opacity: 1;
  }

  43.75% {
    animation-timing-function: cubic-bezier(0.333, 0, 0.657, 1);

    opacity: 0;
  }

  100% {
    animation-timing-function: cubic-bezier(0.333, 0, 0, 1);

    opacity: 0;
  }
}

.square {
  animation: square-animation-main 3.2s infinite;

  background: var(--ring-loader-color-1);
  mask-image: linear-gradient(to top, rgb(0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);

  &,
  &::before,
  &::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    border-radius: 20%;
  }

  &::before {
    content: '';
    animation: square-animation-pseudo 6.4s infinite;

    opacity: 0;

    background: var(--ring-loader-color-2);
  }

  &::after {
    content: '';
    animation: square-animation-pseudo 6.4s 3.2s infinite;

    opacity: 0;

    background: var(--ring-loader-color-3);
  }
}

.inner {
  top: 20px;
  right: 20px;
  bottom: 20px;
  left: 20px;
}

.middle {
  top: 10px;
  right: 10px;
  bottom: 10px;
  left: 10px;

  opacity: 0.8;

  &,
  &::before {
    animation-delay: 0.08s;
  }

  &::after {
    animation-delay: 3.28s;
  }
}

.outer {
  opacity: 0.7;

  &,
  &::before {
    animation-delay: 0.16s;
  }

  &::after {
    animation-delay: 3.36s;
  }
}

.animate {
  animation: rotation-keyframes 36s linear infinite;
}

.text {
  text-align: center;

  font-family: var(--ring-font-family);
  font-size: var(--ring-font-size);
  line-height: var(--ring-line-height);
}
